﻿using System.Collections.Generic;
using Machine.Specifications;

using SportsStore.ReadRepositery.QueryStore.Abstracts;
using SportsStore.ReadRepositery.DataTransferObject;
using SportsStore.ReadRepositery;
using Raven.Client;
using Ploeh.AutoFixture;
using Raven.Client.Document;
using NUnit.Framework;
using Raven.Client.Client;

namespace SportsStore.Test.Viewing_The_Products
{
    public class When_The_Product_Repositery_is_Query_For_All_Products
    {
        static IProductQueryRepositery productRepositery;
        static IEnumerable<ProductDTO> ProductList;
        static IDocumentSession session;

        public When_The_Product_Repositery_is_Query_For_All_Products()
        {
            EmbeddableDocumentStore store = new EmbeddableDocumentStore { DataDirectory=@"C:\Data"};
             store.RunInMemory = true;
             store.Initialize();
             session = store.OpenSession();
        }

         Establish context = () =>
         {
            
             Fixture fixture=new Fixture();
             IEnumerable<ProductDTO> productList = fixture.CreateMany<ProductDTO>(10);
             session.Store(productList);
             session.SaveChanges();
             productRepositery = new ProductQueryRepositery(session);
         };

        Because of = () => 
        {
            ProductList=productRepositery.GetAllProducts();
        };

        It Return_All_The_Product_List = () => 
        {
            
            ProductList.ShouldNotBeNull();
        };
    }
}
